package com.ycwl.library;

import android.app.Application;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.widget.ImageView;

import java.io.IOException;
import java.io.InputStream;

public class UITools {
    public static final String TAG = "UITools";
    public static void SetBitmap(ImageView imageView, String source, AssetManager assetManager) {
        InputStream inputStream = null;
        try {
            inputStream = assetManager.open(source);
            Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
            imageView.setImageBitmap(bitmap);
        } catch (IOException e) {
            Log.e(TAG,"set bitmap fail! " + e.getMessage());
        }finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    Log.e(TAG,"inputStream.close() fail! " + e.getMessage());
                }
            }
        }
    }

}
